</div>
<script type="text/javascript">
function verificarRol (rol) {
  
  if (rol == "2") {
    document.getElementById("sede").disabled = true;
  }else{
    document.getElementById("sede").disabled = false;
  };
  
}

</script>
<div id="principal">
	<section id="parrafo">
	   <div id="container_demo" >
        <div id="wrapper">
          <div id="login" class="animate form">
          	<form name="formulario" action="<?php echo base_url(); ?>usuario/insertar" method="post" enctype="multipart/form-data">
      			 <p> 
                   <label for="usernamesignup" class="uname" >Nombre*</label>
                   <?php echo form_input(array('name'=>'nombre','placeholder'=>'Nombre','required'=>'required','id'=>'usernamesignup','type'=>'text','value'=>set_value('nombre')))?>
              </p>
                 <?php echo form_error('nombre')?>
      		    <p> 
                 <label for="usernamesignup" class="uname" >Apellido*</label>
                 <?php echo form_input(array('name'=>'apellido','placeholder'=>'Apellido','required'=>'required','id'=>'usernamesignup','type'=>'text','value'=>set_value('apellido')))?>
              </p>
                 <?php echo form_error('apellido')?>
              <p>

              <?php
                if ($user['tipo_user'] == "Administrador General") {
              ?>   
                  <label for="usernamesignup" class="uname" >Tipo:</label>
                  <select id="rol"  onchange="verificarRol(this.value);" class="form-control" name="id_rol" >
                    <option value="" >[Seleccione un rol]</option>
                  <?php 
                       
                        foreach ($roles as $rol) {
                  ?>
                          <option value="<?php echo $rol->id_rol;?>" ><?php echo $rol->nombre;?></option>
                  <?php } ?>
                  </select>  
              <?php    
                }else{
                  echo '<input name="id_rol" value="3" type="hidden" />';
                }
              ?>
                                                    
                  <br>
              </p>
      		    <p> 
                 
                 
                  <?php 
                    if ($user['tipo_user'] == "Administrador de Sede") { ?> 
                      <label for="usernamesignup" class="uname" >Subsede </label>
                      <select class="form-control" name="id_subsede">
                     <?php  foreach ($subsedes[$user['id_sede']] as $sub) {                                                                                                          
                  ?>          
                      <option value="<?php echo $sub->id_subsede;?>" ><?php echo $sub->nombre ?></option>      
                  <?php          
                                               
                    }}else{ ?>
                      <label for="usernamesignup" class="uname" >Sede </label>
                      <select id="sede" class="form-control" onchange="cambiarSubsedes()" name="id_subsede">
                    <?php   foreach ($sedes as $row) {                                                                                                          
                        foreach ($subsedes[$row->id_sede] as $sub) {
                  ?>
                          <option value="<?php echo $sub->id_subsede;?>" ><?php echo $sub->nombre.'        |       Sede '.$row->nombre;?></option>              
                  <?php                                                                                                              
                        }
                      }
                    }         
                  ?>
                 </select>
              </p>
              
      		    <p> 
                 <label for="usernamesignup" class="uname" >Email*</label>
                 <?php echo form_input(array('name'=>'email','placeholder'=>'Mi Email','required'=>'required','id'=>'idem','type'=>'text','value'=>set_value('email')))?>
              </p>
                 <?php echo form_error('email')?>
          	   <p>
                  <label for="usernamesignup" class="uname" data-icon="" >DNI*:</label>
                  <?php echo form_input(array('name'=>'dni','placeholder'=>'DNI','required'=>'required','id'=>'usernamesignup','type'=>'number','value'=>set_value('dni')))?>
               </p>
                  <?php echo form_error('dni')?>
                <p>
                  <label for="emailsignup" class="fecha" >Fecha de Nacimiento*:</label>
                  <?php echo form_input(array('name'=>'fecha','id'=>'fechanac','required'=>'required','type'=>'date','value'=>set_value('fecha')))?>
                </p>
                <p>
                   <label for="usernamesignup" class="uname" >Direccion:</label>
                   <div id="direccion-box">
                     <label for="usernamesignup" class="uname" >Calle     /    Numero</label><br>        
                     <?php echo form_input(array('name'=>'calle','required'=>'required','placeholder'=>'Calle','id'=>'inputs-login','type'=>'text','value'=>set_value('calle')))?><br>
                     <?php echo form_input(array('name'=>'numero','required'=>'required','placeholder'=>'Numero','id'=>'inputs-login','type'=>'number','value'=>set_value('numero')))?><br>
                   </div>
                   <?php echo form_error('calle')?>
                   <?php echo form_error('numero')?>
                </p>
                <p>
                  <label for="usernamesignup" class="uname" >Ciudad:</label>
                  <select id="inputs-login" name="id_ciudad"><br>
                        <?php
                            $query = $this->db->get('localidad');
                            foreach ($query->result() as $ciudad) {
                         ?>
                        <option value="<?php echo $ciudad->id_localidad;?>" selected><?php echo $ciudad->nombre;?></option>
                        <?php                                                  
                            } 
                        ?>
                  </select>
                </p>                                                                            
                <p>
                  <label for="usernamesignup" class="uname" >Pais:</label>
                  <select class="form-control" name="id_pais" >
                     <?php 
      			         $query = $this->db->get('pais');
                     foreach ($query->result() as $pais) {
                      ?>
                      <option value="<?php echo $pais->id_pais;?>" ><?php echo $pais->nombre;?></option>
                      <?php } ?>
                  </select>
                  <br>
                  </p>
      						<p>
      						    <label>Imagen:</label>
                      <input type="file" name="imagen" /><br /><br />
                  </p>
          		    <p class="signin button">
                      <input type="submit" name="guardar" value="Guardar" />
                  </p>
      </form>
    </div>
  </div>
  </div>
  </section>
  </div>
</div>
</body>
</html>